From 393d3bab9ef1f6f0243a0c0d0d2c857777956315 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Tue, 8 Nov 2022 15:23:25 +0100
Subject: [PATCH 11/11] drop -latomic on risc and elsewhere

---
 compiler/rustc_llvm/build.rs | 17 +----------------
 src/bootstrap/native.rs      | 13 -------------
 2 files changed, 1 insertion(+), 29 deletions(-)

diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index 230deaeaf..4aaeb1b95 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -240,14 +240,7 @@ fn main() {
         cmd.arg("--system-libs");
     }
 
-    if (target.starts_with("arm") && !target.contains("freebsd"))
-        || target.starts_with("mips-")
-        || target.starts_with("mipsel-")
-        || target.starts_with("powerpc-")
-    {
-        // 32-bit targets need to link libatomic.
-        println!("cargo:rustc-link-lib=atomic");
-    } else if target.contains("windows-gnu") {
+    if target.contains("windows-gnu") {
         println!("cargo:rustc-link-lib=shell32");
         println!("cargo:rustc-link-lib=uuid");
     } else if target.contains("netbsd") || target.contains("haiku") || target.contains("darwin") {
@@ -346,14 +339,6 @@ fn main() {
         "stdc++"
     };
 
-    // RISC-V GCC erroneously requires libatomic for sub-word
-    // atomic operations. Some BSD uses Clang as its system
-    // compiler and provides no libatomic in its base system so
-    // does not want this.
-    if target.starts_with("riscv") && !target.contains("freebsd") && !target.contains("openbsd") {
-        println!("cargo:rustc-link-lib=atomic");
-    }
-
     // C++ runtime library
     if !target.contains("msvc") {
         if let Some(s) = llvm_static_stdcpp {
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index e0d1504c9..d1c124abe 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -386,19 +386,6 @@ impl Step for Llvm {
             cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
         }
 
-        if target.starts_with("riscv") && !target.contains("freebsd") && !target.contains("openbsd")
-        {
-            // RISC-V GCC erroneously requires linking against
-            // `libatomic` when using 1-byte and 2-byte C++
-            // atomics but the LLVM build system check cannot
-            // detect this. Therefore it is set manually here.
-            // Some BSD uses Clang as its system compiler and
-            // provides no libatomic in its base system so does
-            // not want this.
-            ldflags.exe.push(" -latomic");
-            ldflags.shared.push(" -latomic");
-        }
-
         if target.contains("msvc") {
             cfg.define("LLVM_USE_CRT_DEBUG", "MT");
             cfg.define("LLVM_USE_CRT_RELEASE", "MT");
-- 
2.39.0

